package navon.id.programs;

import java.util.Random;

public class Mountainterrain {
	static Random random = new Random();
	Mapgenerator mapvar;
	int xvalue;
	int yvalue;
	int randnumb;

	public Mountainterrain(Mapgenerator mg) {
		this.mapvar = mg;
		xvalue = random.nextInt(19);
		yvalue = random.nextInt(19);
		mapvar.map[xvalue][yvalue] = Mapterrain.MOUNTAIN;
	}

	public void numbchoice() {
		randnumb = random.nextInt(8);
	}

	public void mountainmaker() {
		int randirection0 = random.nextInt(4);
		int randirection1 = random.nextInt(3);
		int randirection2 = random.nextInt(2);
		for (int i = 0; i == randnumb; i++) {
			int randhold0 = randirection0;
			int randhold1 = randirection1;
			int randhold2 = randirection2;
			if (xvalue == 0 && yvalue == 0) {
				if (randhold2 == 0) {
					mapvar.map[xvalue + 1][yvalue] = Mapterrain.MOUNTAIN;
					mapvar.map[xvalue + 1][yvalue] = mapvar.map[xvalue][yvalue];
				} else if (randhold2 == 1)
					mapvar.map[xvalue][yvalue + 1] = Mapterrain.MOUNTAIN;
				mapvar.map[xvalue][yvalue + 1] = mapvar.map[xvalue][yvalue];
			} else if (xvalue == 19 && yvalue == 0) {
				if (randhold2 == 0) {
					mapvar.map[xvalue - 1][yvalue] = Mapterrain.MOUNTAIN;
					mapvar.map[xvalue - 1][yvalue] = mapvar.map[xvalue][yvalue];
				} else if (randhold2 == 1) {
					mapvar.map[xvalue][yvalue + 1] = Mapterrain.MOUNTAIN;
					mapvar.map[xvalue][yvalue + 1] = mapvar.map[xvalue][yvalue];
				}
			} else if (xvalue == 0 && yvalue == 19) {
				if (randhold2 == 0) {
					mapvar.map[xvalue + 1][yvalue] = Mapterrain.MOUNTAIN;
					mapvar.map[xvalue + 1][yvalue] = mapvar.map[xvalue][yvalue];
				} else if (randhold2 == 1) {
					mapvar.map[xvalue][yvalue - 1] = Mapterrain.MOUNTAIN;
					mapvar.map[xvalue][yvalue - 1] = mapvar.map[xvalue][yvalue];
				}
			} else if (xvalue == 19 && yvalue == 19) {
				if (randhold2 == 0) {
					mapvar.map[xvalue - 1][yvalue] = Mapterrain.MOUNTAIN;
					mapvar.map[xvalue - 1][yvalue] = mapvar.map[xvalue][yvalue];
				} else if (randhold2 == 1) {
					mapvar.map[xvalue][yvalue - 1] = Mapterrain.MOUNTAIN;
					mapvar.map[xvalue][yvalue - 1] = mapvar.map[xvalue][yvalue];
				}
			} else if (xvalue != 0 && xvalue != 19) {
				if (yvalue != 0 && yvalue != 19) {
					if (randhold0 == 0) {
						mapvar.map[xvalue + 1][yvalue] = Mapterrain.MOUNTAIN;
						mapvar.map[xvalue + 1][yvalue] = mapvar.map[xvalue][yvalue];
					} else if (randhold0 == 1) {
						mapvar.map[xvalue - 1][yvalue] = Mapterrain.MOUNTAIN;
						mapvar.map[xvalue - 1][yvalue] = mapvar.map[xvalue][yvalue];
					} else if (randhold0 == 2) {
						mapvar.map[xvalue][yvalue + 1] = Mapterrain.MOUNTAIN;
						mapvar.map[xvalue][yvalue + 1] = mapvar.map[xvalue][yvalue];
					} else if (randhold0 == 3) {
						mapvar.map[xvalue][yvalue - 1] = Mapterrain.MOUNTAIN;
						mapvar.map[xvalue][yvalue - 1] = mapvar.map[xvalue][yvalue];
					}
				} else if (yvalue != 0) {
					if (randhold1 == 0) {
						mapvar.map[xvalue + 1][yvalue] = Mapterrain.MOUNTAIN;
						mapvar.map[xvalue + 1][yvalue] = mapvar.map[xvalue][yvalue];
					} else if (randhold1 == 1) {
						mapvar.map[xvalue - 1][yvalue] = Mapterrain.MOUNTAIN;
						mapvar.map[xvalue - 1][yvalue] = mapvar.map[xvalue][yvalue];
					} else if (randhold1 == 2) {
						mapvar.map[xvalue][yvalue - 1] = Mapterrain.MOUNTAIN;
						mapvar.map[xvalue][yvalue - 1] = mapvar.map[xvalue][yvalue];
					}
				} else {
					if (randhold1 == 0) {
						mapvar.map[xvalue + 1][yvalue] = Mapterrain.MOUNTAIN;
						mapvar.map[xvalue + 1][yvalue] = mapvar.map[xvalue][yvalue];
					} else if (randhold1 == 1) {
						mapvar.map[xvalue - 1][yvalue] = Mapterrain.MOUNTAIN;
						mapvar.map[xvalue - 1][yvalue] = mapvar.map[xvalue][yvalue];
					} else if (randhold1 == 2) {
						mapvar.map[xvalue][yvalue + 1] = Mapterrain.MOUNTAIN;
						mapvar.map[xvalue][yvalue + 1] = mapvar.map[xvalue][yvalue];
					}
				}
			} else if (xvalue != 0) {
				if (randhold1 == 0) {
					mapvar.map[xvalue - 1][yvalue] = Mapterrain.MOUNTAIN;
					mapvar.map[xvalue - 1][yvalue] = mapvar.map[xvalue][yvalue];
				} else if (randhold1 == 1) {
					mapvar.map[xvalue][yvalue - 1] = Mapterrain.MOUNTAIN;
					mapvar.map[xvalue][yvalue - 1] = mapvar.map[xvalue][yvalue];
				} else if (randhold1 == 2) {
					mapvar.map[xvalue][yvalue + 1] = Mapterrain.MOUNTAIN;
					mapvar.map[xvalue][yvalue + 1] = mapvar.map[xvalue][yvalue];
				}
			} else {
				if (randhold1 == 0) {
					mapvar.map[xvalue + 1][yvalue] = Mapterrain.MOUNTAIN;
					mapvar.map[xvalue + 1][yvalue] = mapvar.map[xvalue][yvalue];
				} else if (randhold1 == 1) {
					mapvar.map[xvalue][yvalue - 1] = Mapterrain.MOUNTAIN;
					mapvar.map[xvalue][yvalue - 1] = mapvar.map[xvalue][yvalue];
				} else if (randhold1 == 2) {
					mapvar.map[xvalue][yvalue + 1] = Mapterrain.MOUNTAIN;
					mapvar.map[xvalue + 1][yvalue + 1] = mapvar.map[xvalue][yvalue];
				}
			}

		}

	}
}